package com.atwulidun.adapter05.objectdapter;

public class Phone {
    // 充电方法，以适配器类作为入参
    public void charge(VoltageAdapter voltageAdapter) {
        // 通过适配器获得适配后的电压，并判断适不适合给手机充电
        if (voltageAdapter.output5V() == 5) {
            System.out.println("适配器输出电压为5V，适合给手机充电！");
        } else {
            System.out.println("适配器输出电压不为5V，不适合给手机充电！");
        }
    }
}
